package com.probox.common.entity.domain.order;

import java.util.Date;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.util.List;

import com.probox.common.core.enums.OrderStatusEnum;
import com.probox.common.core.enums.PayMethodEnum;
import com.probox.common.core.enums.PayStatusEnum;
import com.probox.common.core.enums.PlatSourceEnum;
import com.probox.common.core.utils.DateUtils;
import com.probox.common.core.utils.money.PriceFormatUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.probox.common.core.annotation.Excel;

/**
 * 充值订单对象 order_recharge
 *
 * @author hds
 * @date 2021-06-07
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("order_recharge")
@ApiModel(description="充值订单")
public class OrderRecharge implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 订单ID
     */
    //默认主键自增
    @TableId(value = "RECHARGE_UID", type = IdType.AUTO)
    private Long rechargeUid;
    /** 平台ID */
    //@Excel(name = "平台ID")
    @ApiModelProperty(value = "平台ID(平台ID)")
    private Long platformUid;

    private Long storeId;

    /** 充值单号 */
    @Excel(name = "充值单号")
    @ApiModelProperty(value = "充值单号(充值单号)")
    private String rechargeNo;

    @Excel(name = "充值项目")
    private String rechargeName;

    /** 客户名称 */
    @Excel(name = "客户名称")
    @ApiModelProperty(value = "客户名称(客户名称)")
    private String customerName;

    /** 手机号码 */
    @Excel(name = "手机号码")
    @ApiModelProperty(value = "手机号码(手机号码)")
    private String phone;

    @TableField(exist = false)
    @Excel(name = "兑换VIP")
    private String levelName;

    @Excel(name = "兑换积分")
    private Long score;

    //@Excel(name = "支付单号")
    //@ApiModelProperty(value = "支付单号(支付单号)")
    private String parentOrderNo;

    @ApiModelProperty(value = "会员级别ID(充值会员必传)")
    private Long levelId;



    /** 客户ID */
    //@Excel(name = "客户ID")
    @ApiModelProperty(value = "客户ID(客户ID)")
    private Long customerUid;





    /** 支付方式 wechat(微信)/alipay(支付宝)/netbank(网银) */
    @Excel(name = "支付方式")
    @ApiModelProperty(value = "支付方式 wechat(微信)/alipay(支付宝)/netbank(网银) )")
    private String payMethod;

    @TableField(exist = false)
    private List<String> payMethodList;

    /** 订单来源(wechat小程序/H5/Web/Android/IOS) */
    //@Excel(name = "订单来源(wechat小程序/H5/Web/Android/IOS)")
    @ApiModelProperty(value = "订单来源(wechat小程序/H5/Web/Android/IOS) ")
    private String platSource;

    /** 订单金额 */
    //@Excel(name = "订单金额")
    @ApiModelProperty(value = "订单金额(订单金额)")
    private Long orderAmount;

    //@Excel(name = "订单金额")
    @TableField(exist = false)
    private String orderAmountFmt;

    /** 支付金额 */
    //@Excel(name = "支付金额")
    @ApiModelProperty(value = "支付金额(支付金额)")
    private Long payAmount;

    /** 支付金额 */
    @Excel(name = "支付金额")
    @TableField(exist = false)
    private String payAmountFmt;

    /** 货币单位 */
    //@Excel(name = "货币单位")
    @ApiModelProperty(value = "货币单位(货币单位)")
    private String currencyUnit;

    /** 订单状态 1:有效 0:未支付取消 -1:过期未支付无效 -2:已支付取消 */
    @Excel(name = "订单状态(1:有效/其他:无效)")
    @ApiModelProperty(value = "订单状态 1:有效 0:未支付取消 -1:过期未支付无效 -2:已支付取消")
    private String orderStatus;

    /** 支付状态 0 未支付/1已支付 */
    @Excel(name = "支付状态(0未支付/1已支付)")
    @ApiModelProperty(value = "支付状态 0 未支付/1已支付(支付状态 0 未支付/1已支付)")
    private String payStatus;

    /** 支付时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "支付时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "支付时间(支付时间)")
    private Date payTime;

    /** 下单时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "下单时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "下单时间(下单时间)")
    private Date createTime;

    /** 订单取消时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    //@Excel(name = "订单取消时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "订单取消时间(订单取消时间)")
    private Date cancelTime;

    /** 买家留言 */
    //@Excel(name = "买家留言")
    @ApiModelProperty(value = "买家留言(买家留言)")
    private String buyMes;

    /** 未支付订单过期时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    //@Excel(name = "未支付订单过期时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "未支付订单过期时间(未支付订单过期时间)")
    private Date expireDate;

    /** 备注 */
    @Excel(name = "备注")
    @ApiModelProperty(value = "备注(备注)")
    private String remark;

    /** ip地址 */
    //@Excel(name = "ip地址")
    @ApiModelProperty(value = "ip地址(ip地址)")
    private String ip;

    public String getOrderType(){
        if(ObjectUtil.isEmpty(levelId))
            return "兑换积分";
        return "VIP订单";
    }

    public String getOrderStatusStr(){
        return OrderStatusEnum.getNameByKey(orderStatus);
    }

    public String getPayStatusStr(){
        return PayStatusEnum.getNameByKey(payStatus);
    }

    public String getPayMethodStr(){
        return PayMethodEnum.getNameByKey(payMethod);
    }

    public String getPlatSourceStr(){
        return PlatSourceEnum.getNameByKey(platSource);
    }

    public String getOrderAmountStr(){
        return PriceFormatUtil.format(orderAmount);
    }

    public String getPayAmountStr(){
        return PriceFormatUtil.format(payAmount);
    }


    public String getPayTimeStr(){
        return DateUtils.formate(payTime);
    }

    public String getCreateTimeStr(){
        return DateUtils.formate(createTime);
    }

    public String getCancelTimeStr(){
        return DateUtils.formate(cancelTime);
    }

    public String getExpireDateStr(){
        return DateUtils.formate(expireDate);
    }

    private Long rechargeId;
    private String firstDouble;
    private int firstDoubleMonth;
    private Long goldCoin;
    private Long silverCoin;

    private String rechargeDesc;



    /**
     * 是否需要分账 (Y-是，需要分账;N-否，不分账)
     */
    @ApiModelProperty(value = "是否需要分账 (Y-是，需要分账;N-否，不分账)")
    private String profitSharing;

    /**
     * 分账状态(0未发起分账/1已发起分账/2已解冻分润)
     */
    @ApiModelProperty(value = "分账状态(0未发起分账/1已发起分账/2已解冻分润)")
    private String isShared;

    //@Excel(name = "门店")
    @TableField(exist = false)
    private String storeName;

    @TableField(exist = false)
    private List<String> payTimeArray;

    @TableField(exist = false)
    private List<Long> storeIds;

    //门店分组
    @TableField(exist = false)
    private Long storeGroupId;

}
